Public Class ingresarGrupo
    Private objG As capaNegocios.Gestor = objG.instanciar()
    Private idG As Integer

    Private Sub ingresarGrupo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.cargarListaCursos()
    End Sub


    Public Sub cargarListaCursos()
        Dim datos As DataTable = objG.mostrarCursos()
        listaCursos.DataSource = datos
        If (listaCursos.RowCount > 0) Then
            Me.Agregar.Enabled = True
        Else
            Me.Agregar.Enabled = False
        End If
    End Sub


    Private Sub Agregar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Agregar.Click
        Dim horario, periodo, asistente As String
        Dim id, fila As Integer
        fila = listaCursos.CurrentRow.Index
        periodo = Me.periodo.Text
        horario = Me.horario.Text
        asistente = Me.asistente.Text
        id = CInt(listaCursos(2, fila).Value)
        Try
            Me.idG = objG.registrarGrupo(periodo, horario, asistente, id)
            Me.verPlan.Enabled = True
            MessageBox.Show("Fue ingresado satisfactoriamente", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Me.DialogResult = Windows.Forms.DialogResult.None
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Me.DialogResult = Windows.Forms.DialogResult.None
            Me.verPlan.Enabled = False
        End Try
    End Sub

    Private Sub Cancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancelar.Click
        Close()
    End Sub

    Private Sub RegistrarCurso_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles registrarCurso.Click
        Using RegistrarCurso As New registrarCurso
            If RegistrarCurso.ShowDialog() = Windows.Forms.DialogResult.OK Then
            End If
            Me.cargarListaCursos()
        End Using
        Me.DialogResult = Windows.Forms.DialogResult.None
    End Sub

    Private Sub verPlan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles verPlan.Click
        Using rub As New modificarEvaluacion
            Dim fila As Integer
            fila = listaCursos.CurrentRow.Index
            rub.cargarDatos(Me.idG, listaCursos(1, fila).Value, periodo.Text(), 1)
            If rub.ShowDialog() = Windows.Forms.DialogResult.OK Then
            End If
            Me.cargarListaCursos()
        End Using
        Me.DialogResult = Windows.Forms.DialogResult.None
    End Sub
End Class